home *** CD-ROM | disk | FTP | other *** search
- /* nearest.c
- * AUTHOR: Cy Booker, cy@cheepnis.demon.co.uk
- * LICENSE: FreeWare, Copyright (c) 1995 Cy Booker
- */
-
- #include "internal.h"
-
- #include <assert.h>
-
- #include "OS:macros.h"
- #include "OS:hourglass.h"
-
-
-
- /* ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- */
-
- extern bool process_gif_8bpp_nearest(
- const process_gif *p) {
- bits *rove;
- bits dest;
- int width, height;
- int x, y;
- int line_length;
- bits t;
- bits pixtrans[256];
-
- assert(p);
- assert(p->pixel_width > 0);
- assert(p->pixel_height > 0);
- assert((p->line_length & 3) == 0);
- assert(p->fn);
- assert(p->in_palette.ncolours < COUNT(pixtrans));
- assert(p->out_palette.colours);
-
- process_gif_calc_pixtrans(p, pixtrans);
-
- /*
- * not we pre-load values from the process_gif array
- * because it considerably helps the compiler produce better code
- */
- rove = (bits *)p->buffer;
- height = p->pixel_height;
- width = ((p->pixel_width + 3) & ~3) >> 2;
- line_length = p->line_length >> 2;
-
- for (y= p->pixel_height; (y > 0); y--) {
- if ((y & 7) == 0) {
- xhourglass_percentage((y * 100) / height);
- }
- for (x= width - 1; (x >= 0); x--) {
- /*
- * reading/writing one 32-bit word is much faster than four bytes
- */
- t = rove[x];
- dest = pixtrans[(t << (3*8)) >> 24] << (0*8);
- dest |= pixtrans[(t << (2*8)) >> 24] << (1*8);
- dest |= pixtrans[(t << (1*8)) >> 24] << (2*8);
- dest |= pixtrans[(t << (0*8)) >> 24] << (3*8);
- rove[x] = dest;
- }
- rove += line_length;
- }
- return FALSE;
- }
-
-
-
-